$(function () {
    let id=localStorage.getItem("updataById")
    userFindById(id);
})

function userFindById(id){
    let da={
        id:id,
    }
    let data=myAjax("/user/findById",da,"post");
    data=data.userbean;
    $("#code").val(data.code);
    $('#userType option[value=' + data.typeCode + ']').attr('selected',true);//下拉框选择器
    $("#name").val(data.name);
    $("input[name='sex'][value="+data.sex+"]").attr("checked",true);
    $("#age").val(data.age);
    $("#education").val(data.education);
    $("#university").val(data.university);
    $("#naative").val(data.naative);
    $("#address").val(data.address);
    $("#phone").val(data.phone);
    $("#otherphone").val(data.otherphone);
}

function userUpdate() {
    let da={
        id:localStorage.getItem("updataById"),
        code:$("#code").val(),
        typeCode:$("#userType").val(),
        name:$("#name").val(),
        sex:$("input[name='sex']:checked").val(),
        age:$("#age").val(),
        education:$("#education").val(),
        university:$("#university").val(),
        naative:$("#naative").val(),
        address:$("#address").val(),
        phone:$("#phone").val(),
        otherphone:$("#otherphone").val(),
        groupCode:$("#group-code").val(),
    }
    let data=myAjax("/user/update",da,"post");
    data=data.result;
    if (data==1){
        alert("修改成功!");
        $('#middle-reght').load('user/user.html');
    }else {
        alert("修改失败!");
    }
}
